﻿using Soundteller.AudioVisual.Model;
using Soundteller.Common.Tests;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Soundteller.AudioVisual.Tests.Unit.Model.IntersectionCalculatorSpecifications
{
    public abstract class WhenIntersectsTestBase : TestBase
    {
        public abstract int PointX { get; }
        public abstract int PiontY { get; }
        public abstract int AreaX { get; }
        public abstract int AreaY { get; }
        public abstract int AreaWidth { get; }
        public abstract int AreaHeight { get; }
        public bool Result { get; private set; }

        protected override void Act()
        {
            Result = IntersectionCalculator.Intersects(PointX, PiontY, AreaX, AreaY, AreaWidth, AreaHeight);
        }
    }

    [TestClass]
    public class WhenIntersectsGivenPointIntersects : WhenIntersectsTestBase
    {
        public override int PointX { get { return 1; } }
        public override int PiontY { get { return 1; } }
        public override int AreaX { get { return 0; } }
        public override int AreaY { get { return 0; } }
        public override int AreaWidth { get { return 2; } }
        public override int AreaHeight { get { return 2; } }

        [TestMethod]
        public void ThenResultShouldBeTrue()
        {
            Assert.IsTrue(Result);
        }
    }

    [TestClass]
    public class WhenIntersectsGivenPointX_DoesNotIntersect : WhenIntersectsTestBase
    {
        public override int PointX { get { return 3; } }
        public override int PiontY { get { return 1; } }
        public override int AreaX { get { return 0; } }
        public override int AreaY { get { return 0; } }
        public override int AreaWidth { get { return 2; } }
        public override int AreaHeight { get { return 2; } }

        [TestMethod]
        public void ThenResultShouldBeFalse()
        {
            Assert.IsFalse(Result);
        }
    }

    [TestClass]
    public class WhenIntersectsGivenPointY_DoesNotIntersect : WhenIntersectsTestBase
    {
        public override int PointX { get { return 1; } }
        public override int PiontY { get { return 3; } }
        public override int AreaX { get { return 0; } }
        public override int AreaY { get { return 0; } }
        public override int AreaWidth { get { return 2; } }
        public override int AreaHeight { get { return 2; } }

        [TestMethod]
        public void ThenResultShouldBeFalse()
        {
            Assert.IsFalse(Result);
        }
    }

    [TestClass]
    public class WhenIntersectsGivenPointX_AndY_DoNotIntersect : WhenIntersectsTestBase
    {
        public override int PointX { get { return 3; } }
        public override int PiontY { get { return 3; } }
        public override int AreaX { get { return 0; } }
        public override int AreaY { get { return 0; } }
        public override int AreaWidth { get { return 2; } }
        public override int AreaHeight { get { return 2; } }

        [TestMethod]
        public void ThenResultShouldBeFalse()
        {
            Assert.IsFalse(Result);
        }
    }
}
